package logic

import (
	"context"
	"errors"
	"medi-manage/medirpc/internal/svc"
	"medi-manage/medirpc/medirpc"
	"medi-manage/models"

	"github.com/zeromicro/go-zero/core/logx"
)

type MediAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMediAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MediAddLogic {
	return &MediAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 添加
func (l *MediAddLogic) MediAdd(in *medirpc.MediAddRequest) (*medirpc.MediAddResponse, error) {
	// todo: add your logic here and delete this line
	var medi models.Medi
	err := medi.MediAdd(models.DB)
	if err != nil {
		return nil, errors.New("添加失败")
	}
	return &medirpc.MediAddResponse{
		MeidId: int64(medi.ID),
	}, nil
}
